package com.ms.auction.auth.oauth2.service;

import com.ms.auction.auth.system.entity.TbUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * Created by fp295 on 2018/11/25.
 */
@Slf4j
@Service
public class UsernameUserDetailService extends AbstractUserDetailService{

    @Override
    protected  TbUser getUser(String username) {
        // 手机验证码调用FeignClient根据电话号码查询用户
        TbUser tbUser= tbUserService.getByUsername(username);
        if(tbUser == null){
            log.error("找不到该用户，用户名：" + username);
            throw new UsernameNotFoundException("找不到该用户，用户名：" + username);
        }
        return tbUser;
    }


}
